package com.alan.test.base;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.alan.http.HttpParameter;
import com.alan.http.HttpUtils;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn_translate).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("MainActivity","onClick");
                HttpParameter.HttpParameterBuilder builder = HttpParameter.builder();
                builder.add("city","北京市");
                builder.add("pageNo","1");
                HttpUtils.getAsync(builder.build(), new HttpUtils.OnHttpCallback() {
                    @Override
                    public void onSuccess(String message) {
                        Log.d("MainActivity","onSuccess:"+message+" thread:"+Thread.currentThread().getName());
                    }

                    @Override
                    public void onFailure(Throwable e) {
                        Log.d("MainActivity","onFailure:"+e.getMessage()+" thread:"+Thread.currentThread().getName());
                    }
                });
            }
        });

    }
}